package lib.bone.access.validator;

import lib.bone.access.constant.WorkloadSourceConst;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class IsWorkloadSourceValidator implements ConstraintValidator<IsWorkloadSource, Object> {
    @Override
    public void initialize(IsWorkloadSource constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(Object o, ConstraintValidatorContext constraintValidatorContext) {
        String type = o.toString();
        if (type.equals(WorkloadSourceConst.LEADER) || type.equals(WorkloadSourceConst.MANAGER)||type.equals((WorkloadSourceConst.APPLY))){
            return true;
        }
        return false;
    }
}
